fix(corekit): reparent the unblocked non-registry enums onto EnumLookup (#877) - #921
Conversation
db5953a to
21c9b28
Compare
|
Cross-review on Opus returned NEEDS CHANGES (author was Sonnet). Both findings were prose, both are now fixed — new head The code was sound; two comments asserted something measurement refutes. I re-derived both myself on What was wrong. The delegation is exception-compatible for every key the signature admits (
No caller can reach any of it: the only live sites are Also corrected: the pre-fix failure count is 31 Verified after the amend: 51 tests across |
|
GOOD TO GO at head The two load-bearing claims, measured independently:
Worth recording from the reviewer, correcting its own earlier framing: the template is a Behaviour is unchanged from One item remains UNVERIFIED and is not blocking: the Unpublished and unmerged — yours to merge. Note the merge-order constraint recorded on #922. |
|
We may want to revise if their overrides after subclassing |
|
Ruling recorded, verbatim:
Measured before answering, on
So neither override is redundant — but each is down to a small, nameable job. Deleting either would be a public behaviour change, not a cleanup: a name miss would start raising Which leaves a real design question, and it is yours: is the Labelled |
|
Either |
…up (#877) Phase 2 of #877, the 11 classes across 8 files not held by #913/#904: TransportProtocol, FinalisedState, Completion, ftp.Type, httpv1.Type, Criticality, PDUKind, PacketDirection, PacketReception, WireGuardKeyLabel, and FrameType.Flags (carrying its 6 per-frame subclasses transitively). Each now mixes in EnumLookup ahead of its enum base for the shared get/get_all contract. TransportProtocol and Criticality already had their own get, both as a staticmethod against EnumLookup.get's classmethod (the #908/#915 trap). Both are now classmethods delegating to super().get(), keeping only what the base does not reproduce -- TransportProtocol's case-fold and no-mint refusal, Criticality's case-sensitive miss -- each re-raised as the ValueError callers already depend on rather than the base's KeyError. Each gained a default parameter forwarded to the base, since dropping one the base declares is a real classmethod-override violation under mypy. Updated test_const_enum_get.py's exclusion set for TransportProtocol's new default, and added test_enum_lookup_reparent_877_unit.py pinning the re-parenting, both preserved overrides, and no member-table growth.
21c9b28 to
3e7d73d
Compare
|
Ruling recorded, verbatim:
Measured on Python 3.14.7, so the shape the ruling selects is concrete: Two consequences, and one gap I did not expect:
Filed as #923 ( Removing Also rebased onto |
|
So the overloads are still legit? Or they will be fixe/updated in #923? |
|
Both: legitimate as shipped here, then reduced in #923. Measured rather than assumed. Legitimate now. Each override still does something the inherited base does not, so nothing in this PR ships dead code:
#923 removes the conversion, and that is what changes each of them. Under the ruling — stdlib shape,
The only thing lost by deleting it is the narrower One thing I went looking for and did not find, so it is not a defect to fix: I expected the So: merge this as-is, and #923 does the reduction. I have recorded the above in #923's scope so the two-into-one shrink is not rediscovered there. |
… onto EnumLookup (#930) Finishes #877's phase 2, which #921 left seven classes out of because their files were held by #913/#904 at the time: CommandType and ConformanceRequirement (const/ftp/command.py), ESPStatus (protocols/internet/esp.py), and FastBindingAcknowledgmentStatus, IPv6AddressPrefixCode, LMAAddressCode and LocalizedRoutingStatus (protocols/internet/mh.py). Both blockers have since merged. Each now mixes in EnumLookup ahead of its enum base; member-table sizes are unchanged. FastBindingAcknowledgmentStatus and IPv6AddressPrefixCode kept their own get, still a staticmethod that never calls super() -- left untouched, since #923's EnumKeyError name-miss conversion already matches the base's shape. mypy's [override] and pylint's arguments-differ against the kept decorator are suppressed rather than resolved by widening it. The other five are pure re-parents. Brought conventions.rst and its own doc-claims test in line with #929, which merged in the interim: phase 2 is now 24 of 24, zero enumerations outside the hierarchy. Added test_enum_lookup_reparent_930_unit.py pinning the re-parenting, the kept overrides, no growth, and the zero-outside census; fixed three tests whose claims this change made stale (test_const_enum_get, test_const_ftp_featcode_case_903_unit, test_mh_unit). Build: mypy/pylint/isort clean against baseline; affected test files pass.
|
Correction to this PR's description, for the record. It says Measured from the API: #904 touched neither file. Its file list is The This does not change anything this PR did — the 11 classes it re-parented were the right set, and the seven it deferred were genuinely contended. Surfaced while reviewing #932, which finished those seven and had inherited the same misattribution from here. |
… onto EnumLookup (#930) Finishes #877's phase 2, which #921 left seven classes out of because their files were held by #913/#904 at the time: CommandType and ConformanceRequirement (const/ftp/command.py), ESPStatus (protocols/internet/esp.py), and FastBindingAcknowledgmentStatus, IPv6AddressPrefixCode, LMAAddressCode and LocalizedRoutingStatus (protocols/internet/mh.py). Both blockers have since merged. Each now mixes in EnumLookup ahead of its enum base; member-table sizes are unchanged. FastBindingAcknowledgmentStatus and IPv6AddressPrefixCode kept their own get, still a staticmethod that never calls super() -- left untouched, since #923's EnumKeyError name-miss conversion already matches the base's shape. mypy's [override] and pylint's arguments-differ against the kept decorator are suppressed rather than resolved by widening it. The other five are pure re-parents. Brought conventions.rst and its own doc-claims test in line with #929, which merged in the interim: phase 2 is now 24 of 24, zero enumerations outside the hierarchy. Added test_enum_lookup_reparent_930_unit.py pinning the re-parenting, the kept overrides, no growth, and the zero-outside census; fixed three tests whose claims this change made stale (test_const_enum_get, test_const_ftp_featcode_case_903_unit, test_mh_unit). Build: mypy/pylint/isort clean against baseline; affected test files pass.
… onto EnumLookup (#930) Finishes #877's phase 2, which #921 left seven classes out of because their files were held by #913/#904 at the time: CommandType and ConformanceRequirement (const/ftp/command.py), ESPStatus (protocols/internet/esp.py), and FastBindingAcknowledgmentStatus, IPv6AddressPrefixCode, LMAAddressCode and LocalizedRoutingStatus (protocols/internet/mh.py). Both blockers have since merged. Each now mixes in EnumLookup ahead of its enum base; member-table sizes are unchanged. FastBindingAcknowledgmentStatus and IPv6AddressPrefixCode kept their own get, still a staticmethod that never calls super() -- left untouched, since #923's EnumKeyError name-miss conversion already matches the base's shape. mypy's [override] and pylint's arguments-differ against the kept decorator are suppressed rather than resolved by widening it. The other five are pure re-parents. Brought conventions.rst and its own doc-claims test in line with #929, which merged in the interim: phase 2 is now 24 of 24, zero enumerations outside the hierarchy. Added test_enum_lookup_reparent_930_unit.py pinning the re-parenting, the kept overrides, no growth, and the zero-outside census; fixed three tests whose claims this change made stale (test_const_enum_get, test_const_ftp_featcode_case_903_unit, test_mh_unit). Build: mypy/pylint/isort clean against baseline; affected test files pass.
… onto EnumLookup (#932) Finishes #877's phase 2, which #921 left seven classes out of because their files were held by #913/#904 at the time: CommandType and ConformanceRequirement (const/ftp/command.py), ESPStatus (protocols/internet/esp.py), and FastBindingAcknowledgmentStatus, IPv6AddressPrefixCode, LMAAddressCode and LocalizedRoutingStatus (protocols/internet/mh.py). Both blockers have since merged. Each now mixes in EnumLookup ahead of its enum base; member-table sizes are unchanged. FastBindingAcknowledgmentStatus and IPv6AddressPrefixCode kept their own get, still a staticmethod that never calls super() -- left untouched, since #923's EnumKeyError name-miss conversion already matches the base's shape. mypy's [override] and pylint's arguments-differ against the kept decorator are suppressed rather than resolved by widening it. The other five are pure re-parents. Brought conventions.rst and its own doc-claims test in line with #929, which merged in the interim: phase 2 is now 24 of 24, zero enumerations outside the hierarchy. Added test_enum_lookup_reparent_930_unit.py pinning the re-parenting, the kept overrides, no growth, and the zero-outside census; fixed three tests whose claims this change made stale (test_const_enum_get, test_const_ftp_featcode_case_903_unit, test_mh_unit). Build: mypy/pylint/isort clean against baseline; affected test files pass.
Please follow the guide below
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix-- corrects a defectDescription of your pull request and other information
Phase 2 of #877, the owner's ruling to reparent every non-registry enum onto
EnumLookup. This covers the 11 classes across 8 files not held by #913 or #904:TransportProtocol,FinalisedState,Completion,ftp.Type,httpv1.Type,Criticality,PDUKind,PacketDirection,PacketReception,WireGuardKeyLabel, andFrameType.Flags(which carries its 6 concrete per-frame subclasses transitively -- verified at runtime, not assumed).TransportProtocolandCriticalityalready defined their ownget, both as astaticmethodagainstEnumLookup.get'sclassmethod-- the exact trap #908 hit and #915 fixed. Both are nowclassmethods delegating tosuper().get(), keeping only the behaviour the base doesn't reproduce (case-folding and the PR #836 no-mint refusal forTransportProtocol; case-sensitivity forCriticality), each still raising theValueErrorcallers already depend on rather than the base'sKeyError. Each gained adefaultparameter forwarded verbatim to the base, since dropping an optional parameter the base declares is a realclassmethod-override violation under mypy.pcapkit/const/ftp/command.py(CommandType,ConformanceRequirement) andpcapkit/protocols/internet/{esp,mh}.pyare untouched, still held by #913/#904 respectively.